Developer Documentation
PATH  Mac OS X Documentation > Developer Tools > The Objective-C Compiler


Previous | Contents | Next

Compiling C++ Programs

C++ source files conventionally use one of the suffixes .C , .cc , .cpp , or .cxx ; preprocessed C++ files use the suffix .ii . GNU CC recognizes files with these names and compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc ). Objective-C++ (mixed Objective-C and C++) source files use a .M suffix by convention.

However, C++ programs often require class libraries as well as a compiler that understands the C++ language--and under some circumstances, you might want to compile programs from standard input, or otherwise without a suffix that flags them as C++ programs. g++ is a program that calls GNU CC with the default language set to C++, and automatically specifies linking against the GNU class library libg++. On many systems (but not Windows NT), the script g++ is also installed with the name c++ .

When you compile C++ programs, you may specify many of the same command-line options that you use for compiling programs in any language; or command-line options meaningful for C and related languages; or options that are meaningful only for C++ programs. See See Options Controlling C Dialect , for explanations of options for languages related to C. See See Options Controlling C++ Dialect , for explanations of options that are meaningful only for C++ programs.


The Objective-C Compiler

Previous | Contents | Next